package com.tdam2012.grupo04.messageWeb;

import java.util.List;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class Handler extends DefaultHandler {
	
	protected boolean isOK = true;
	protected String message;
	private List<MessageWeb> messages;
	
	public Handler(){
	}
	
	public boolean isOK() {
		return isOK;
	}
	
	
	public String getMessage() {
		return message;
	}

	public List<MessageWeb> getMessages() {
		return messages;
	}

	@Override
	public void startElement(String uri, String localName, String qName,
			Attributes attributes) throws SAXException {
		super.startElement(uri, localName, qName, attributes);
		if(localName.equals("result") && attributes.getValue("type").equals("error")){
			isOK= false;
		}
		if(localName.equals("detail")){
			message= attributes.getValue("description");
		}
	}
	
}